#coding=utf-8
'''
Created on 2013-9-8

@author: Ben

资源数据
'''

import MarketGoodsVO

#当前功勋榜宝箱数
featBoxNum = 0
#当前功勋榜档次
featListLv = 0
#所有档次奖励宝箱信息
featListLvs = []

#当前免费祭祀次数
freeWorshipNum = 0

#当前集市次数
marketNum = 0
#当前集市商品
marketGoods = []

#当前未领取军资次数
nationFeedNum = 0

'''
更新功勋榜数据
'''
def updateFeatList(data):
    global featBoxNum
    global featListLv
    global featListLvs
    if 'featBoxNum' in data:
        featBoxNum = data['featBoxNum']
    if 'lv' in data:
        featListLv = data['lv']
    if 'lvs' in data:
        featListLvs = []
        for lvInfo in data['lvs']:
            if 'rewardNum' in lvInfo:
                featListLvs.append(lvInfo['rewardNum'])
                
'''
当前档次完成获得的宝箱数
'''
def getNextFeatListBoxNum():
    global featListLv
    global featListLvs
    if featListLv > len(featListLvs):
        return 0
    else:
        return featListLvs[featListLv-1]

'''
更新祭祀数据
'''
def updateWorship(data):
    global freeWorshipNum
    if 'currentIncenseNum' in data:
        freeWorshipNum = data['currentIncenseNum']
    
'''
更新集市数据
'''
def updateMarket(data):
    global marketNum
    global marketGoods
    if 'nowBuyNum' in data:
        marketNum = data['nowBuyNum']
    marketGoods = []
    if 'products' in data:
        for goodsObj in data['products']:
            marketGoods.append(MarketGoodsVO.MarketGoodsVO(goodsObj))

'''
更新军资数据
'''
def updateNationFeed(data):
    global nationFeedNum
    if 'residueNum' in data:
        nationFeedNum = data['residueNum']

'''
退出游戏时清理数据
'''
def clear():
    pass